//<!-- 配置路由 -->

import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)


//重写push|replace
let originPush = VueRouter.prototype.push;
let originReplace = VueRouter.prototype.replace;

VueRouter.prototype.push = function (location, resolve, reject) {
    if (resolve && reject) {
        originPush.call(this, location, resolve, reject)
    } else {
        originPush.call(this, location, () => {
        }, () => {
        })
    }
}
VueRouter.prototype.replace = function (location, resolve, reject) {
    if (resolve && reject) {
        originReplace.call(this, location, resolve, reject)
    } else {
        originReplace.call(this, location, () => {
        }, () => {
        })
    }
}

//引入路由
import Home from "@/views/Home";
import ApplyLibraryCard from "@/views/ReaderManage/ApplyLibraryCard";
import ApplyDetail from "@/views/ReaderManage/ApplyDetail";
import ChangeLibraryCardInfo from "@/views/ReaderManage/ChangeLibraryCardInfo";
import ChangeLibraryCardInfoDetail from "@/views/ReaderManage/ChangeLibraryCardInfoDetail";
import ReportLoss from "@/views/ReaderManage/ReportLoss";
import CancellationLossReport from "@/views/ReaderManage/CancellationLossReport";
import PostRegisterCard from "@/views/ReaderManage/PostRegisterCard";
import AccountCancellation from "@/views/ReaderManage/AccountCancellation";
import AddBook from "@/views/BookManage/AddBook";
import UpdateBook from "@/views/BookManage/UpdateBook";
import Edit from "@/views/BookManage/UpdateBook/Edit";
import Login from "@/views/login";
import BorrowBook from "@/views/BorrowManage/BorrowBook";
import RenewBook from "@/views/BorrowManage/RenewBook";
import ReturnBook from "@/views/BorrowManage/ReturnBook";
import Borrow from "@/views/BorrowManage/BorrowBook/Borrow";
import UpdateLogin from "@/views/UpdateLogin";

export default new VueRouter({
    mode: "history",
    routes: [
        {
            path: '/home',
            component: Home,
            meta: {
                showPageHeader: false,
            }
        },
        {
            path: '/reader/applyForLibraryCard',
            component: ApplyLibraryCard,


        },
        {
            path: "/reader/applyForLibraryCard/apply",
            component: ApplyDetail,

        },
        {
            path: "/reader/changeLibraryCardInfo",
            component: ChangeLibraryCardInfo,

        },
        {
            name: "edit",
            path: "/reader/changeLibraryCardInfo/edit",
            component: ChangeLibraryCardInfoDetail,
            params: {
                result: []
            },

        },
        {
            path: "/reader/reportLoss",
            component: ReportLoss,

        },
        {
            path: "/reader/cancelReportLoss",
            component: CancellationLossReport,

        },
        {
            path: "/reader/postRegisterCard",
            component: PostRegisterCard,

        },
        {
            path: "/reader/cancelAccount",
            component: AccountCancellation,

        },
        {
            path: "/book/addBook",
            component: AddBook,

        },
        {
            path: "/book/updateBook",
            component: UpdateBook,

        },
        {
            path: "/book/updateBook/edit",
            component: Edit,

        },
        {
            path: '/',
            component: Login,
            meta: {
                requiresAuth: false, // false表示不需要登录
            },
        }
        ,
        {
            name: 'login',
            path: "/login",
            component: Login,
            meta: {
                title: '登录',
                requiresAuth: false, // false表示不需要登录
            },
        },
        {
            path: "/borrow/borrowBook",
            component: BorrowBook,

        },
        {
            path: "/borrow/renewBook",
            component: RenewBook,

        },
        {
            path: "/borrow/returnBook",
            component: ReturnBook,
        },
        {
            path: "/borrow/borrowBook/borrow",
            component: Borrow,
        },
        {
            name:'updateLogin',
            path:"/updateLogin",
            component:UpdateLogin
        }
    ]
})
